﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IBLL;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Model;

namespace MedicalSystem.Controllers
{
    public class DoctorController : Controller
    {
        
        private readonly IDoctorBLL _bll;
        private readonly IPatientBLL _blls;
        private readonly IProfessionalBLL _bllp;

        public DoctorController( IDoctorBLL bll, IPatientBLL blls, IProfessionalBLL bllp)
        {
             
            _bll = bll;
            _blls = blls;
            _bllp = bllp;
        }



        /// <summary>
        /// 医生界面显示
        /// </summary>
        /// <returns></returns>
        /// 

        public IActionResult DoctorIndex()
        {
            return View();
        }

        /// <summary>
        /// 医生添加登记数据及界面
        /// </summary>
        /// <returns></returns>
        public IActionResult DoctorAdd()
        {
            return View();
        }



        /// <summary>
        /// 医生界面显示
        /// </summary>
        /// <returns></returns>
        /// 

        public IActionResult DoctorUpdate()
        {
            return View();
        }

        /// <summary>
        /// 显示数据
        /// </summary>
        /// <param name="Doctorname"></param>
        /// <returns></returns>
        [HttpGet]

        public JsonResult GetDoctorsLists(string Doctorname)
        {
            return Json(_bll.GetDoctorsList(Doctorname));
        }

        [HttpPost]
        /// <summary>
        /// 登记医生信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult AddDoctor(Doctor model)
        {
            return Json(_bll.AddDoctorDAL(model));
        }
        [HttpGet]
        /// <summary>
        /// 根据id查询单条数据（编辑详情）
        /// </summary>
        /// <param name="did"></param>
        /// <returns></returns>
        public JsonResult GetDoctorById(int did)
        {
            return Json(_bll.GetDoctorById(did));
        }
        [HttpGet]
        /// <summary>
        /// 查询单条数据（返回信息）
        /// </summary>
        /// <param name="doctor"></param>
        /// <returns></returns>
        public JsonResult UpdateDoctor(Doctor doctor)
        {
            return Json(_bll.UpdateDoctorDAL(doctor));
        }

        /// <summary>
        /// 查询科室信息（下拉框绑定）
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public JsonResult GetOutpatient()
        {
            return Json(_blls.GetOutpatient());
        }
        /// <summary>
        /// 查询医生职称信息（下拉框绑定）
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public JsonResult GetProfessionals()
        {
            return Json(_bllp.GetProfessionalsShow());
        }
    }
}

